/*
 * 
 *  This file is part of Sourceprojects.org Lycia Copyright 2010 noctarius
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */
package org.sourceprojects.lycia.internal.logging;

import org.sourceprojects.lycia.internal.platform.PlatformSupportUtils;

public abstract class LyciaLoggerWrapper {
	public static enum LyciaLoggerType {
		Android, Log4j, JavaLogging
	}

	private static LyciaLoggerType loggerType = null;

	private final String tag;

	LyciaLoggerWrapper(final String tag) {
		this.tag = tag;
	}

	public static final void setLyciaLoggerType(final LyciaLoggerType loggerType) {
		LyciaLoggerWrapper.loggerType = loggerType;
	}

	public static final LyciaLoggerWrapper getLogger(final Class<?> clazz) {
		final String canonicalName = clazz.getCanonicalName();

		if (loggerType == null) {
			if (PlatformSupportUtils.isDalvikDependingPlatform()) {
				return new AndroidCompatibleLogger(canonicalName);
			} else if (PlatformSupportUtils.isLog4jAvailable()) {
				return new Log4jLogger(canonicalName);
			}

			return new JavaLoggingLogger(canonicalName);
		} else {
			switch (LyciaLoggerWrapper.loggerType) {
			case Android:
				return new AndroidCompatibleLogger(canonicalName);
			case Log4j:
				return new Log4jLogger(canonicalName);
			default:
				return new JavaLoggingLogger(canonicalName);
			}
		}
	}

	protected String getTag() {
		return tag;
	}

	public abstract void debug(Object message);

	public abstract void debug(Object message, Throwable t);

	public abstract void warn(Object message);

	public abstract void warn(Object message, Throwable t);

	public abstract void error(Object message);

	public abstract void error(Object message, Throwable t);

	public abstract void fatal(Object message);

	public abstract void fatal(Object message, Throwable t);

	public abstract void info(Object message);

	public abstract void info(Object message, Throwable t);

	public abstract boolean isDebugEnabled();

}
